<?php
namespace  Teachers\Controller;
use Admin\Controller\IndexController;

use Think\Controller;

/**
 * 招生计划
 * @author chl
 *
 */
class PlanController extends CommonController
{
	public $category_id;	//高招-招生计划55
	public $pagesize;
	
	public function index()
	{

		$school_id=$this->showschoolID();
		$type=I('get.type');
		$categoryids = array(
			'GZ'	=>	'55',
			'YK'	=>	'59',
			'YZ'	=>	'51'
		);
		$category_id=$categoryids[$type];
		$pagesize = 2;
		$document_data=$this->showSchoolArticle($school_id, $category_id,0,I('get.p',1),$pagesize);
		$this->assign("document_data",$document_data);
		$count      = $this->getArticleCount($school_id, $category_id,0);
		$Page       = new \Think\Page($count,$pagesize);
		$show       = $Page->show();// 分页显示输出
		$this->assign('page',$show);// 赋值分页输出
		$this->assign('school_id',$school_id);// 赋值分页输出
		$this->assign('category_id',$category_id);// 赋值分页输出
		$this->display();
	
	}
	
	/**
	 *编辑ajax获取信息内容 
	 */
	public function ajaxArticle(){
		$id=I('post.id');
		$data=$this->getArticleById($id);
		$this->ajaxReturn($data);
	}
	 
	/**
	 * 新增学校各项类别信息
	 * 
	 * */
	public function addSchoolArticle()
	{
            $school_id=$this->showschoolID();
		if($school_id && $_POST['category_id']){
			$post_data =I('post.');
			$this->addArticle($post_data);
		}
		$this->redirect('Teachers/News/index',$params, 0, '页面跳转中...');
	}
	
	
	/**
	 *更新学校各项类别信息
	 * 
	 * */
	public function updateSchoolArticle()
	{
            $school_id=$this->showschoolID();
		$post_data =I('post.');
		if($school_id && $_POST['article_id']){
			$this->updateArticle($post_data);
		}
	}
	
	
	 /**
	  * 删除各项类别信息
	  *  假删除 更新状态位为-1
	  **/
	public function deleteSchoolArticle()
	{
		$article_id=I('post.id');
		$this->deleteArticle($article_id);
		$this->ajaxReturn($article_id);
	}

}